<template>
  <div class="container">
    <van-nav-bar
      title="邀约成功"
      @click-left="onClickLeft"
      style="z-index: 1001"
      fixed
    >
      <van-icon name="arrow-left" slot="left" color="#333" size="0.6rem" />
    </van-nav-bar>

    <div class="list">
      <div class="item">
        <span>邂逅宣言 </span>
        <span>在北京遇到爱情 </span>
      </div>

      <p class="line"></p>
      <div class="item">
        <span>邀约时间</span>
        <span>2021年8月20日 12:00</span>
      </div>
      <p class="line"></p>

      <div v-if="clickItem != null" class="item">
        <span>已选套餐</span>
        <span>{{ clickItem.title }} / ￥{{ clickItem.price }}</span>
      </div>
      <p v-if="clickItem != null" class="line"></p>
    </div>

    <div
      style="
        background: white;
        text-align: right;
        display: right;
        padding-bottom: 10px;
      "
    >
      <van-button
        style="
          width: 100px;
          height: 35px;
          margin-right: 10px;
          line-height: 35px;
        "
        type="info"
        color="#55A79A"
        @click="
          () => {
            show = true;
          }
        "
        >{{ clickItem != null ? '修改菜品' : '预定菜品' }}</van-button
      >
    </div>
    <van-popup
      v-model="show"
      closeable
      close-icon="close"
      position="bottom"
      :style="{ height: '55%' }"
    >
      <div class="pop-list">
        <div class="pop-item" v-for="item in popList" @click="selectItem(item)">
          <img width="80" height="80" :src="item.url" />
          <div>
            <p>{{ item.title }}</p>
            <p>￥{{ item.price }}</p>
          </div>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script>
export default {
  data() {
    return {
      show: false,
      clickItem: null,
      popList: [
        {
          title: '黄金套餐',
          price: 999,
          url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20180428%2Ff8893bda99c14289a35d13b7ad4f4720.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1631978242&t=e14366271bec3f494a56b474088ccdc6',
        },
        {
          title: '白银套餐',
          price: 666,
          url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fp0.meituan.net%2Fdeal%2Fbac1f81f9b3fe1c390cac4fc77dd6ffb185210.jpg&refer=http%3A%2F%2Fp0.meituan.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1631978242&t=dd6fb4d6be036b1d1ce6b91bdf0e72cf',
        },
        {
          title: '青铜套餐',
          price: 333,
          url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20180824%2Fdb81e187a21147d388ab268d80a7bfc4.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1631978242&t=ff922c181623e38433c5ac14007aca35',
        },
      ],
    };
  },
  methods: {
    onClickLeft(type) {
      this.$router.back(-1);
    },

    selectItem(item) {
      this.clickItem = item;
      this.show = false;
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: 44px;
  box-sizing: border-box;
}

.grid {
  margin-top: 10px;
  margin: 15px 0;
  display: flex;
  flex-direction: row;
  background-color: white;

  & > .item {
    display: flex;
    flex: 1;
    padding: 8px 0;
    text-align: center;
    flex-direction: column;
    & > span:first-child {
      color: black;
      font-size: 20px;
      margin-bottom: 5px;
      font-weight: bold;
    }

    & > span:last-child {
      color: gray;
      font-size: 16px;
    }
  }
}

.line {
  height: 1px;
  background-color: #e5e5e5;
}
.list {
  display: flex;
  flex-direction: column;
  padding: 5px 10px;
  background-color: white;

  & > .item {
    display: flex;
    padding: 8px 0;
    align-items: center;
    flex-direction: row;
    & > span:first-child {
      color: black;
      font-size: 16px;
      text-align: left;
      flex: 1;
    }

    & > span:last-child {
      color: gray;
      font-size: 16px;
    }
  }
}

.pop-list {
  margin-top: 40px;
  display: flex;
  flex-direction: column;

  & > .pop-item {
    display: flex;
    padding: 10px 15px;
    align-items: center;
    border-bottom: 1px solid #e5e5e5;

    & > div {
      display: flex;
      margin-left: 15px;
      flex-direction: column;

      & > p:first-child {
        font-size: 18px;
      }

      & > p:last-child {
        margin-top: 10px;
        color: red;
        font-size: 20px;
      }
    }
  }
}
</style>